<template>
  <div>
    <el-form-item label="最小值">
      <el-input-number
        v-model="localData.min"
        controls-position="right"
        placeholder="最小值"
        :max="localData.max - 1"
        :min="0"
      />
    </el-form-item>
    <el-form-item label="最大值">
      <el-input-number
        v-model="localData.max"
        controls-position="right"
        placeholder="最大值"
        :min="localData.min + 1"
      />
    </el-form-item>
    <el-form-item label="步长">
      <el-input-number
        v-model="localData.step"
        controls-position="right"
        placeholder="步长"
        :min="0"
        :max="localData.max - localData.min"
      />
    </el-form-item>
    <el-form-item label="显示离散值">
      <el-switch v-model="localData.showStops" />
    </el-form-item>
    <el-form-item label="显示输入框">
      <el-switch v-model="localData.showInput" />
    </el-form-item>
    <el-form-item label="范围选择">
      <el-switch v-model="localData.range" />
    </el-form-item>
  </div>
</template>

<script>
export default {
  name: 'ConfigSlider',
  props: {
    data: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      localData: {}
    }
  },
  watch: {
    data: {
      handler(newVal) {
        if (newVal) {
          this.localData = newVal
        }
      },
      deep: true,
      immediate: true
    },
    localData: {
      handler(newVal) {
        this.$emit('update:data', newVal)
      },
      deep: true
    }
  }
}
</script>
